package codeCreate;

import codeCreate.strategyService.StrategyService;
import codeCreate.strategyService.impl.BeanToJsonStringStrategy;
import codeCreate.strategyService.impl.CreateApiDocumentStrategy;
import codeCreate.strategyService.impl.ServiceStrategy;
import codeCreate.util.TextAnalysis.ApplyMessageCodeController;

public class CodeCreateUtil {
    private StrategyService strategyService;

    public void create(StrategyService<?> strategyService) {
        this.strategyService = strategyService;
        try {
            strategyService.create();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private String create() {
        try {
            return (String) strategyService.create();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public void createService() {
        this.strategyService = new ServiceStrategy();
        create();
    }

    public String createBeanJson(Class<?> beanClass) {
        this.strategyService = new BeanToJsonStringStrategy(beanClass);
        return create();
    }

    public String createWordFile(String filePath, Class<?>[] clazz) {
        this.strategyService = new CreateApiDocumentStrategy(filePath, clazz);
        return create();
    }

    public static void main(String[] args) {
        Class<?>[] clazz = { ApplyMessageCodeController.class };
        CodeCreateUtil codeCreateUtil = new CodeCreateUtil();
        // codeCreateUtil.createBeanJson(DeviceCriteria.class);
        codeCreateUtil.createWordFile("C:/Users/Administrator/Desktop/docTest/test.docx", clazz);
    }
}
